package com.bawei.room.controller;

import java.util.Arrays;
import java.util.Map;


import com.alibaba.fastjson.JSON;
import com.bawei.room.vo.QueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bawei.room.entity.LiveStreamingEntity;
import com.bawei.room.service.LiveStreamingService;
import com.bawei.common.utils.PageUtils;
import com.bawei.common.utils.R;



/**
 * 
 *
 * @author LK
 * @email 1419801767@qq.com
 * @date 2021-12-09 20:45:34
 */
@RestController
@RequestMapping("roomLiving/livestreaming")
public class
LiveStreamingController {

    @SuppressWarnings("all")
    @Autowired
    private LiveStreamingService liveStreamingService;


    /**
     * 列表
     */
    @PostMapping("/list")
    //public R list(@RequestParam Map<String, Object> params){
    public R list(@RequestBody QueryVo vo){
        PageUtils page = liveStreamingService.queryPage(vo);
        String s = JSON.toJSONString(page.getList());
        System.out.println(s);
        System.out.println();
        System.out.println();
        String s1 = JSON.toJSONString(page);
        System.out.println(s1);
        return R.ok().put("page", page);
    }


    @GetMapping("/updateRoomStatus/{roomId}/{status}")
    public R updateRoomStatus(@PathVariable("roomId")Integer roomId,@PathVariable("status")Integer status){
        return liveStreamingService.updateRoomStatus(roomId,status);
    }



    /**
     * 信息
     */
    @PostMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		LiveStreamingEntity liveStreaming = liveStreamingService.getById(id);
        return R.ok().put("liveStreaming", liveStreaming);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody LiveStreamingEntity liveStreaming){
		liveStreamingService.save(liveStreaming);
        return R.ok();
    }



    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody LiveStreamingEntity liveStreaming){
		liveStreamingService.updateById(liveStreaming);
        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		liveStreamingService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
